#include <iostream>
#include <string>
#include <cmath>

bool isPrime(int num) {
    if(num <= 1) {
        return false;
    }
    for(int i = 2; i <= sqrt(num); i++) {
        if(num % i == 0) {
            return false;
        }
    }
    return true;
}

int getNumber(std::string word) {
    if(word == "zero") {
        return 0;
    } else if(word == "one") {
        return 1;
    } else if(word == "two") {
        return 2;
    } else if(word == "three") {
        return 3;
    } else if(word == "four") {
        return 4;
    } else if(word == "five") {
        return 5;
    } else if(word == "six") {
        return 6;
    } else if(word == "seven") {
        return 7;
    } else if(word == "eight") {
        return 8;
    } else if(word == "nine") {
        return 9;
    }
    return -1;
}

int main() {
    std::string word1, word2, word3;
    std::cin >> word1 >> word2 >> word3;

    int num1 = getNumber(word1);
    int num2 = getNumber(word2);
    int num3 = getNumber(word3);

    if(num1 == -1 and num2 == -1 and num3 == -1) {
        std::cout << "wrong input" << std::endl;
        return 0;
    }

    int number = num1 * 100 + num2 * 10 + num3;
    int prime = number;

    while(!isPrime(prime)) {
        prime++;
    }

    std::cout << prime << std::endl;

    return 0;
}
